#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/7/13 10:36
# @Author  : LiShan
# @Email   : lishan_1997@126.com
# @File    : start vissim.py
# @Note    : this is note
import os
import os.path as pt
import string


def get_disklist():
  disk_list = []
  for c in string.ascii_uppercase:
    disk = c + ':'
    if os.path.isdir(disk):
      disk_list.append(disk)
  return disk_list


def search_file(path):
    for root, dirs, files in os.walk(path):
        for f in files:
            file_path = pt.abspath(pt.join(root, f))
            if file_path.endswith("vissim.exe"):
                return file_path
    return None


if __name__ == '__main__':
    # path = r"E:\Program Files (x86)\PTV_Vision\VISSIM430\Exe\vissim.exe"
    path = None
    for disk in get_disklist():
        path = search_file(disk + r"\Program Files (x86)\PTV_Vision")
        if path is not None:
            print(path)
            command = r'RunAsDate.exe /movetime 01\01\2008 00:04:10 "%s"' % path
            os.system(command)
            break
        else:
            pass
    else:
        print("未找到vissim软件")
